<?php
	/**
	 * 添加优惠券前置操作
	 */
	function coupon_add_before($model, $action){
		
		$array['rule']   = $_POST['rule'];   //任意条件（random）、 所有条件（all）
		$array['rulend'] = $_POST['rulend']; //符合（accord）、不符合（unaccord）
		$array['config'] = array(
			'column' => array(
				'con' => $_POST['treeSelect'],
				'id'  => $_POST['menuValue'],
			),
			'brand' => array(
				'con' => $_POST['brandValue'],
				'id'  => $_POST['barndValue'],
			),
			'product' => array(
				'con' => $_POST['productSelect'],
				'id'  => $_POST['productValue'],
			),
			'level' => array(
				'con' => $_POST['levelSelect'],
				'id'  => $_POST['levelValue'],
			),
			'group' => array(
				'con' => $_POST['groupSelect'],
				'id'  => $_POST['groupValue'],
			),
			'ordernum' => array(
				'con' => $_POST['numSelect'],
				'id'  => $_POST['orderNum'],
			),
			'ordertotal' => array(
				'con' => $_POST['totalSelect'],
				'id'  => $_POST['orderTotal'],
			),
		);
		
		$arr = $_POST['attrValue'];
		foreach($arr as $k=>$v){
			$config = $arr[$k];
		}
		
		$query['type']    = $model->type;
		$query['config']  = $arr;
		
		$model->config = json_encode($array);
		$model->attr   = json_encode($query);
		
		return $model;
	}
?>
